package com.application.fabric.users.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

@Configuration
public class Corconfig {
    @Bean
    public CorsFilter corsFilter() {
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        CorsConfiguration config = new CorsConfiguration();
        config.addAllowedOrigin("*"); // 允许所有来源跨域访问
        config.addAllowedHeader("*"); // 允许所有请求头跨域访问
        config.addAllowedMethod("*"); // 允许所有请求方法跨域访问
        source.registerCorsConfiguration("/**", config);
        return new CorsFilter(source);
    }
}



